package com.jxufe.getData;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class MyRunnable implements Runnable {
	private String code;
	public void run() {
		String url = "https://www.tianqiapi.com/api/?version=v1&&cityid=" + code;
		System.out.println(url);
		String str;
		try {
			str = Resouce.run(url);
			JSONObject json = JSON.parseObject(str);
			Resouce.write(json);
			Resouce.writeSign(code);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			synchronized (Resouce.lock) {
				Resouce.count++;
				Resouce.logger.info(Resouce.count);
				if (Resouce.count >= Resouce.size) {
					Resouce.logger.info("notify:"+Resouce.count);
					Resouce.lock.notify();
				}
			}
		}
		return;
	}
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

}